<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 开发环境版本 -->
    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <style>
      .center {
        width: 800px;
        height: 460px;
        border: 10px solid aqua;
        position: relative;
      }
      img {
        width: 800px;
      }
      .center .left {
        position: absolute;
        left: 0;
        top: calc(50% - 50px);
        display: block;
        border: 1px solid black;
        background-color: bisque;
        width: 30px;
        height: 100px;
      }
      .center .right {
        position: absolute;
        right: 0;
        top: calc(50% - 50px);
        display: block;
        border: 1px solid black;
        background-color: bisque;
        width: 30px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div id="mask">
      <div class="center">
        <!-- 图片 -->
        <img :src="imgArr[index]" alt="" />
        <!-- 左箭头 -->
        <a
          href="javascript:void(0)"
          v-show="index!=0"
          @click="prev"
          class="left"
          >←</a
        >
        <!-- 右箭头 -->
        <a
          href="javascript:void(0)"
          v-show="index<imgArr.length-1"
          @click="next"
          class="right"
        >
          →
        </a>
      </div>
    </div>
    <script>
      var app = new Vue({
        el: "#mask",
        data: {
          imgArr: ["01.jpg", "02.jpg", "03.jpg", "04.jpg", "05.jpg"],
          index: 0,
        },
        methods: {
          prev: function () {
            this.index--;
          },
          next: function () {
            this.index++;
          },
        },
      });
    </script>
  </body>
</html>
